package org.ccay.log.webtrace.impl;

import org.apache.log4j.NDC;
import org.ccay.core.exception.ApplicationException;
import org.ccay.core.request.IUserPrincipal;
import org.ccay.core.support.session.IAfterRequestContextBuildHandler;
import org.ccay.core.support.session.RequestEventArgs;

/**
 * Web Trace 入栈管理器，不再需要了，Name 已经注释掉
 * @author chaowangbang
 * @since 2012-5-30
 */
public final class WebTraceInHandler implements IAfterRequestContextBuildHandler{
 
	/* (non-Javadoc)
	 * @see www.ccay.org.ccay.core.support.session.IBeforeRequestHandler#execute(java.lang.Object, www.ccay.org.ccay.core.support.session.RequestEventArgs)
	 */
	public void execute(Object sender, RequestEventArgs args) throws ApplicationException {
		if( !WebTraceStatusManager.isWebTraceEnabled ){			 
			return ;
		}
		IUserPrincipal user = args.getUser();
		
		if(user != null  && 
				user.getUserName().equals(WebTraceStatusManager.userAccount2Trace)){
			NDC.push(user.getUserName());
		}				 
	}
}
 
